/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.ArrayList;
import java.util.List;
import java.util.function.LongToIntFunction;

/**
 * <p>Project: javaseapp - Fun01
 * <p>Powered by webrx On 2021-08-20 15:19:31
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Fun01 {
    public static void main(String[] args) {
        List<Student> list = new ArrayList<>();
        list.add(new Student(1, "李四", 30));
        list.add(new Student(2, "赵六", 90));
        list.add(new Student(3, "张三丰", 80));
        list.add(new Student(4, "李强", 70));

        list.stream()
                .filter(e -> e.getName().startsWith("李"))
                .forEach(e -> System.out.println(e.getName()));

        System.out.println("---------------------------------");
        for (Student st : list) {
            System.out.println(st.getName());
        }

        list.forEach(System.out::println);
        list.stream()
                .map(e -> e.getScore() + 1)
                .forEach(e -> System.out.printf("成绩：%d分%n", e));

        System.out.println(list);

        //java 8 内置函数式接口简单使用
        LongToIntFunction fun1 = (e) -> (int) (e * e);
        System.out.println(fun1.applyAsInt(10L));
        ;
    }
}
